var { ReturnModel } = require('../libs/resmodel');
var { peopleSave, peopleSaveBack, peopleList, peopleListBack, peopleQueryOne,
    peopleQueryOneBack, peopleImport, peopleImport_hand, peopleMyinviter, peopleSecret, peopleSecretEdit, peopleExport, peopleSend, peopleSet,peopleNoTop, UnLock, saveRemarks } = require('../services/people');
var { personlabelSave } = require('../services/personlabel');
var { persondesSave } = require('../services/persondes');
var { sendhome } = require('../services/dailyuser');

/**
* 保存用户信息
* @api {post} /people/save 保存用户信息
* @apiDescription 接口根据phone判断，有数据覆盖所传字段信息，无数据新增用户
* @apiName save
* @apiParam (参数) {String} code 用户编号code
* @apiParam (参数) {String} invitcode 推荐人code
* @apiParam (参数) {String} phone 用户手机号
* @apiParam (参数) {String} wechat_code 用户微信号
* @apiParam (参数) {String} inviterphone 推荐人手机号
* @apiParam (参数) {String} nickname 用户昵称
* @apiParam (参数) {String} name 用户姓名
* @apiParam (参数) {String} signature 签名
* @apiParam (参数) {Number} age 年龄
* @apiParam (参数) {String} grender 性别
* @apiParam (参数) {String} wechat_code 微信号
* @apiParam (参数) {String} remark 备注信息
* @apiParam (参数) {float} longitude 经度
* @apiParam (参数) {float} latitude 维度
* @apiParam (参数) {Date} birthday 生日
* @apiParam (参数) {String} star 星座
* @apiParam (参数) {Number} height 身高（cm）
* @apiParam (参数) {Number} weight 体重（kg）
* @apiParam (参数) {String} device 登录设备信息
* @apiParam (参数) {String} address 地址
* @apiParam (参数) {String} province 省份
* @apiParam (参数) {String} city 城市
* @apiParam (参数) {String} area 所在区
* @apiParam (参数) {String} marital_status 婚姻状态 枚举：未婚、已婚、离异无孩、离异带孩、离异不带孩、丧偶
* @apiParam (参数) {String} education 学历 高中及以下（1）、中专（2）、大专（3）、本科（4）、硕士（5）、博士（6）
* @apiParam (参数) {String} education_code 学历编码 高中及以下（1）、中专（2）、大专（3）、本科（4）、硕士（5）、博士（6）
* @apiParam (参数) {String} university 毕业院校
* @apiParam (参数) {String} company 所在公司
* @apiParam (参数) {String} position 担任职位
* @apiParam (参数) {String} year_income 年收入，单位万
* @apiParam (参数) {String} isopen 平台不公开 0：公开 1：不公开公开（默认0）
* @apiParam (参数) {String} islook 主页不公开 0：公开 1：不公开（默认0）
* @apiParam (参数) {String} relationship 与推荐人关系: 朋友、同事等
* @apiParam (参数) {String} synopsis 推荐人简介
* @apiParam (参数) {String} soldier 是否军人
* @apiParam (参数) {String} idcard 身份证号
* @apiParam (参数) {String} house 房产信息-（征婚地有房、临结婚地有房、家乡地有房、打算婚后购房、无房）
* @apiParam (参数) {String} car 是否购车-（有车、近期购车、无车）
* @apiParam (参数) {String} marry 希望何时结婚-（尽快结婚、1-2年内结婚、不着急结婚）
* @apiParam (参数) {Object} self_description 自我描述
* @apiParam (参数) {Object} ideal_partner 理想另一半
* @apiSampleRequest /people/save
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "code": "290464549598",
*       "invitcode": "138359400020",
*       "phone": "13100000000",
*       "nickname": "会飞的鱼",
*       "signature": "寻找我的另一半",
*       "age": 27,
*       "grender": "男",
*       "wechat_code": "13100000000",
*       "remark": "13100000000",
*       "longitude": "13100000000",
*       "latitude": "13100000000",
*       "birthday": "1995-02-01",
*       "star": "金牛座",
*       "height": 180,
*       "weight": 80,
*       "self_description": //自我描述
*        { 
*            "remarks":"寻一人度余生",
*             "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*        }, 
*         "ideal_partner": //理想另一半
*        {  
*            "remarks":"寻一人度余生",
*             "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*        } 
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "保存成功",
*      "code": 0
*   }
*/
async function save(req, res) {
    let result = await peopleSave(req.body);
    res.json(new ReturnModel(result));
}
/**
* 保存用户信息-后台
* @api {post} /people/saveBack 保存用户信息-后台
* @apiDescription 接口根据phone判断，有数据覆盖所传字段信息，无数据新增用户
* @apiName saveBack
* @apiParam (参数) {String} phone 用户手机号
* @apiParam (参数) {String} nickname 用户昵称
* @apiParam (参数) {String} name 用户姓名
* @apiParam (参数) {String} signature 签名
* @apiParam (参数) {Number} age 年龄
* @apiParam (参数) {String} grender 性别
* @apiParam (参数) {String} wechat_code 微信号
* @apiParam (参数) {Date} birthday 生日
* @apiParam (参数) {String} star 星座
* @apiParam (参数) {Number} height 身高（cm）
* @apiParam (参数) {Number} weight 体重（kg）
* @apiParam (参数) {String} address 地址
* @apiParam (参数) {String} province 省份
* @apiParam (参数) {String} city 城市
* @apiParam (参数) {String} area 所在区
* @apiParam (参数) {String} town 所在街道
* @apiParam (参数) {String} hometown 家乡
* @apiParam (参数) {String} marital_status 婚姻状态 枚举：未婚、已婚、离异无孩、离异带孩、离异不带孩、丧偶
* @apiParam (参数) {String} education 学历
* @apiParam (参数) {String} university 毕业院校
* @apiParam (参数) {String} company 所在公司
* @apiParam (参数) {String} position 担任职位
* @apiParam (参数) {String} year_income 年收入，单位万
* @apiParam (参数) {String} inviterphone 推荐人手机号
* @apiParam (参数) {String} isopen 平台不公开 0：公开 1：不公开公开（默认0）
* @apiParam (参数) {String} islook 主页不公开 0：公开 1：不公开（默认0）
* @apiParam (参数) {String} relationship 与推荐人关系: 朋友、同事等
* @apiParam (参数) {String} synopsis 推荐人简介
* @apiParam (参数) {String} soldier 是否军人
* @apiParam (参数) {String} idcard 身份证号
* @apiParam (参数) {String} house 房产信息-（征婚地有房、临结婚地有房、家乡地有房、打算婚后购房、暂无）
* @apiParam (参数) {String} car 是否购车-（有车、近期购车、无车）
* @apiParam (参数) {String} marry 希望何时结婚-（尽快结婚、1-2年内结婚、不着急结婚）
* @apiParam (参数) {Object} self_description 自我描述
* @apiParam (参数) {Object} ideal_partner 理想另一半
* @apiSampleRequest /people/save
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "phone": "13100000000",
*       "nickname": "会飞的鱼",
*       "signature": "寻找我的另一半",
*       "age": 27,
*       "grender": "男",
*       "wechat_code": "13100000000",
*       "remark": "13100000000",
*       "longitude": "13100000000",
*       "latitude": "13100000000",
*       "birthday": "1995-02-01",
*       "star": "金牛座",
*       "height": 180,
*       "weight": 80,
*       "self_description": //自我描述
*        { 
*            "remarks":"寻一人度余生",
*             "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*        }, 
*         "ideal_partner": //理想另一半
*        {  
*            "remarks":"寻一人度余生",
*             "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*        } 
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "保存成功",
*      "code": 0
*   }
*/
async function saveBack(req, res) {
    let result = await peopleSaveBack(req.body);
    res.json(new ReturnModel(result));
}
/**
* 获取用户列表
* @api {post} /people/list 获取用户列表
* @apiDescription 根据请求条件查询用户列表
* @apiName list
* @apiParam (参数) {Number} pagenum 查询第几页
* @apiParam (参数) {Number} pagesize 每页显示条数
* @apiParam (参数) {String} pcode 用户code
* @apiSampleRequest /people/list
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*     "pagenum": 1,  // 查询第几页
*     "pagesize": 10,  // 每页显示条数
*     "pcode":"242178531839"
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "data": {
*              "list": [{"nickname":"xxxx","phone":"13xxxxxx"},{"nickname":"xxxx","phone":"13xxxxxx",
* isfans: 1,//是否收藏此用户，1收藏，0未收藏
* inviter：{"nickname":"推荐人昵称","avator":"推荐人头像"}，
*}],
*              "total": 200,//总条数
*              "pagecount": 20,//总页数
*       },
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function list(req, res) {
    let result = await peopleList(req.body);
    res.json(new ReturnModel(result));
}
/**
* 获取用户列表-后台
* @api {post} /people/listBack 获取用户列表-后台
* @apiDescription 根据请求条件查询用户列表-后台
* @apiName listBack
* @apiParam (参数) {Object} filter 查询条件
* @apiParam (参数) {Object} select 查询字段，多字段英文逗号隔开，不传查所有字段，敏感字段已经屏蔽
* @apiParam (参数) {Number} pagenum 查询第几页
* @apiParam (参数) {Number} pagesize 每页显示条数
* @apiSampleRequest /people/listBack
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*     filter: {
*       "invitcode": "290464549598",
*       "isphoto": 1 // 上传相册，1：是，0：否
*     },
*     "select": "nickname,phone",  // 查询字段逗号隔开
*     "pagenum": 1,  // 查询第几页
*     "pagesize": 10,  // 每页显示条数
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "data": {
*              "list": [
*               {"nickname":"xxxx","phone":"13xxxxxx","inviteer":'邀请人',"recommender": "推荐人"},
*               {"nickname":"xxxx","phone":"13xxxxxx","inviteer":'邀请人',"recommender": "推荐人"}}],
*           },
*       "total": 200,//总条数
*        "pagecount": 20,//总页数
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function listBack(req, res) {
    let result = await peopleListBack(req);
    res.json(new ReturnModel(result));
}
/**
* 获取用户信息
* @api {post} /people/QueryOne 获取用户信息
* @apiDescription 根据用户code获取用户信息
* @apiName QueryOne
* @apiParam (参数) {String} code 用户code 
* @apiParam (参数) {String} pcode 当前用户code //自己访问自己信息，此字段不传（或code==pcode）
* @apiParam (参数) {String} type ==inviter时，获取推荐人资料
* @apiSampleRequest /people/QueryOne
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*       "code":"290464549598",
*       "pcode":"242178531839",
*       "type":"inviter"
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {// 返回参数参考保存传入参数，此处只列出其他参数
*      "data": {
*         "isfans":1, // 是否收藏 1收藏 0未收藏
*         "code":"290464549598", // 用户系统code
*         "nickname":"昵称", 
*         "level":1, // 等级 枚举值：0：游客 1：已认证 9：推荐人
*         "signature":"个性签名", 
*         "age":28, // 年龄
*         "grender":"女", // 性别
*         "birthday":"1994/04/21", // 生日
*         "star":"天蝎座", // 星座
*         "height":170, // 身高
*         "weight":70, // 体重
*         "city":"长沙市", // 所在地
*         "province_town":"湖北省", // 籍贯
*         "cross_realname_auth":1, // 是否实名认证
*         "cross_work_auth":1, // 是否工作认证
*         "cross_education_auth":1, // 是否学历认证
*         "marital_status":"未婚", // 婚姻状况
*         "education":"本科", // 学历
*         "education_code":4, // 学历编码 高中及以下（1）、中专（2）、大专（3）、本科（4）、硕士（5）、博士（6）
*         "university":"xxx大学", // 毕业学校
*         "position":"总经理", // 职位
*         "year_income":"5-10万", // 年收入
*         "inviter_wechat_code":"130xxx", // 推荐人手机号
*         "is_father":1, // 是否家长
*         "state":0, // 状态 枚举值：0：单身（默认值）1:已脱单 9:已婚
*         "reliability": 30, // 可信度 每个认证占比30%，全部认证完成98%
*         "statu": 0, // 用户匹配状态 0：未匹配 1：已匹配  2： 已脱单  9：已下线
*         "isinviter": 0, // 是否推荐人
*         "viterState":0,// 推荐人申请状态  // 0：未申请  1：申请通过 2：申请中 9：申请失败  
*         "inviter"：{"nickname":"推荐人昵称","avator":"推荐人头像"}，----add
*         "islook": 0, // 相册查看权限 (0:公开，1：不公开，2：申请中，3：申请被拒绝)
*         "matchset": //恋爱标准
*                     {
*                       "age": "20-25",  // 身高要求
*                       "height":"165-175", // 体重要求
*                       "city":"深圳市", // 城市
*                       "education":"本科以上", // 学历
*                       "marital_status":"不限", // 婚况
*                      }, 
*         "self_description": //自我描述
*                     {
*                       "type": "self_description",    
*                       "remarks":"寻一人度余生",
*                       "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*                      }, 
*         "family_back": //家庭背景
*                     {
*                       "type": "family_back",    
*                       "remarks":"寻一人度余生",
*                       "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*                      }, 
*         "hobby": //兴趣爱好
*                     {
*                       "type": "hobby",    
*                       "remarks":"寻一人度余生",
*                       "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*                      } 
*         "ideal_partner": //理想另一半
*                     {
*                       "type": "ideal_partner",    
*                       "remarks":"寻一人度余生",
*                       "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*                      } 
*         "my_label": { //我的标签
*                      "character": "开朗,斯文,大方",
*                      "contour": "港风,朋克,复古",
*                      "currentstate": "消息秒回,想恋爱,健身中",
*                      "interest": "吃货,军事迷,爬山",
*                      }, 
*      },
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function QueryOne(req, res) {
    let result = await peopleQueryOne(req.body);
    res.json(new ReturnModel(result));
}
/**
* 获取用户信息-后台
* @api {post} /people/QueryOneBack 获取用户信息-后台
* @apiDescription 根据用户code获取用户信息-后台
* @apiName QueryOneBack
* @apiParam (参数) {Object} code 用户code 
* @apiSampleRequest /people/QueryOneBack
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*       "code":"290464549598",
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {// 返回参数参考保存传入参数，此处只列出其他参数
*      "data": {
*         "isfans":1, // 是否收藏 1收藏 0未收藏
*         "code":"290464549598", // 用户系统code
*         "level":0,// 等级 枚举值：0：游客 1：已认证 9：推荐人
*         "state":0, // 状态 枚举值：0：单身（默认值）1:已脱单 9:已婚
*         "cross_realname_auth": false, // 是否通过实名认证  0未认证，1认证通过，2：认证中，9认证失败
*         "cross_work_auth": false, // 是否通过工作认证  0未认证，1认证通过，2：认证中，9认证失败
*         "cross_education_auth": false, // 是否通过学历认证  0未认证，1认证通过，2：认证中，9认证失败
*         "reliability": 30, // 可信度 每个认证占比30%，全部认证完成98%
*         "statu": 0, // 用户匹配状态 0：未匹配 1：已匹配  2： 已脱单  9：已下线
*         "isinviter": 0, // 是否推荐人
*         "description": [ // 描述信息  自我描述、家庭背景、兴趣爱好、理想的另一半 
*                     {
*                       "type": "self_description",   //self_description: 自我描述、family_back: 家庭背景、hobby:兴趣爱好、ideal_partner:理想的另一半 
*                       "remarks":"寻一人度余生",
*                       "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*                      }, 
*                     {
*                       "type": "family_back",    
*                       "remarks":"寻一人度余生",
*                       "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*                      }, 
*                     {
*                       "type": "ideal_partner",    
*                       "remarks":"寻一人度余生",
*                       "imgs": ["http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test1.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test2.jpg","http://redspider.oss-cn-shenzhen.aliyuncs.com/redspider_v1.0/248161509426_test3.jpg"]
*                      } 
*          ],
*         "my_label": {
*                      "character": "开朗,斯文,大方",
*                      "contour": "港风,朋克,复古",
*                      "currentstate": "消息秒回,想恋爱,健身中",
*                      "interest": "吃货,军事迷,爬山",
*                      }, 
*      },
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function QueryOneBack(req, res) {
    let result = await peopleQueryOneBack(req.body);
    res.json(new ReturnModel(result));
}

/**
* 保存我的标签
* @api {post} /people/personlabelsave 保存我的标签
* @apiDescription 接口根据pcode判断，有数据覆盖所传字段信息，无数据新增
* @apiName personlabelsave
* @apiParam (参数) {String} pcode 关联员工code
* @apiParam (参数) {String} character 性格
* @apiParam (参数) {String} contour 外形
* @apiParam (参数) {String} currentstate 当前状态
* @apiParam (参数) {String} interest 兴趣
* @apiSampleRequest /people/personlabelsave
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598",
*       "character": "开朗,斯文,大方",
*       "contour": "港风,朋克,复古",
*       "currentstate": "消息秒回,想恋爱,健身中",
*       "interest": "吃货,军事迷,爬山",
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "保存成功",
*      "code": 0
*   }
*/
async function personlabelsave(req, res) {
    let result = await personlabelSave(req.body);
    res.json(new ReturnModel(result));
}
/**
* 保存用户描述信息
* @api {post} /people/persondessave 保存用户描述信息
* @apiDescription 保存用户描述信息，如：自我描述、家庭背景，兴趣爱好、理想另一半、单身原因（暂无）
* @apiName persondessave
* @apiParam (参数) {String} pcode 关联员工code
* @apiParam (参数) {String} type 类型如下： self_description: 自我描述、family_back: 家庭背景、hobby:兴趣爱好、ideal_partner:理想的另一半
* @apiParam (参数) {String} remarks 描述
* @apiSampleRequest /people/persondessave
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598",
*       "type": "self_description",
*       "remarks": "以前喜欢一个人", // 限定500字符，前端设置500字限长（参照二狗单身狗）
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "保存成功",
*      "code": 0
*   }
*/
async function persondessave(req, res) {
    let result = await persondesSave(req.body);
    res.json(new ReturnModel(result));
}
/**
* 用户批量导入-后台
* @api {post} /people/peopleimport 用户批量导入-后台
* @apiDescription 请先批量上传用户相册图片，然后再操作用户导入
* @apiName peopleimport
* @apiParam (参数) {File} files 用户信息excel文件，只可上传一个
* @apiSampleRequest /people/peopleimport
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
 *     {
 *         "files": [{ "path": "xxxx", "name": "test.jpg","Content-Length":12000,size: ....}],// 文件信息
 *     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "导入成功",
*      "code": 0
*   }
*/
async function peopleimport(req, res) {
    let result = await peopleImport(req);
    res.json(new ReturnModel(result));
}
async function peopleimport_hand(req, res) {
    let result = await peopleImport_hand(req);
    res.json(new ReturnModel(result));
}
/**
* 我的用户
* @api {post} /people/myinviter 我的用户
* @apiDescription 我的用户-获取推荐人邀请的用户列表
* @apiName myinviter
* @apiParam (参数) {String} pcode 用户code
* @apiSampleRequest /people/myinviter
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598"
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*        "data":[
*            {
*                "nickname":"昵称",
*                "code":"290464549598",
*                "avator":"用户头像",
*                "state":0,// 状态 枚举值：0：单身（默认值）1:已脱单 9:已婚
*                "age":29,
*               "grender":"男",
*                "statu":0,// 用户匹配状态 0：未匹配 1：已匹配  2： 已脱单  9：已下线
*                "createtime":"2022-03-21 15:21",
*            }
*        ]
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function myinviter(req, res) {
    let result = await peopleMyinviter(req.body);
    res.json(new ReturnModel(result));
}
/**
* 我的隐私管理
* @api {post} /people/peoplesecret 我的隐私管理
* @apiDescription 我的隐私管理-获取用户隐私管理配置
* @apiName peoplesecret
* @apiParam (参数) {String} pcode 用户code
* @apiSampleRequest /people/peoplesecret
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598"
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "data":{
*                "isschool": 0, // 隐藏学校名称，0：不隐藏，1：隐藏
*                "iscompany": 0, //隐藏公司名称，0：不隐藏，1：隐藏
*                "islocal": 0, //隐藏位置信息，0：不隐藏，1：隐藏
*                "issecret":0, //屏蔽同事，0：不屏蔽，1：屏蔽
*                "isopen":0, //平台不公开，0：不公开，1：公开
*                "islook": 0 //主页不公开，0：不公开，1：公开
*       },
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function peoplesecret(req, res) {
    let result = await peopleSecret(req.body.pcode);
    res.json(new ReturnModel(result));
}
/**
* 保存用户隐私设置
* @api {post} /people/peoplesecretEdit 保存用户隐私设置
* @apiDescription 保存用户隐私设置-当隐私设置发生变化时触发保存
* @apiName peoplesecretEdit
* @apiParam (参数) {String} pcode 用户code
* @apiParam (参数) {Number} isschool 隐藏学校名称，0：不隐藏，1：隐藏
* @apiSampleRequest /people/peoplesecretEdit
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598"
*       "isschool": 1
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "保存成功",
*      "code": 0
*   }
*/
async function peoplesecretEdit(req, res) {
    let result = await peopleSecretEdit(req.body);
    res.json(new ReturnModel(result));
}
/**
* 导出用户列表-后台
* @api {post} /people/peopleexport 导出用户列表-后台
* @apiDescription 根据请求条件查询用户列表并导出-后台
* @apiName peopleexport
* @apiParam (参数) {Object} filter 查询条件
* @apiSampleRequest /people/peopleexport
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*     filter: {
*       "invitcode": "290464549598"
*     },
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "导出成功",
*      "code": 0
*   }
*/
async function peopleexport(req, res) {
    let result = await peopleExport(req.body);
    if (result.code) {
        res.json(new ReturnModel(result));
    } else {
        res.setHeader('Content-Type', 'application/octet-stream');
        res.setHeader('Content-Disposition', 'attachment;filename=' + encodeURI(result.filename));
        res.status(200).send(result.buffer);
    }
}
/**
* 用户发布/回收-后台
* @api {post} /people/peoplesend 用户回收-后台
* @apiDescription 用户回收后在小程序首页不会展示
* @apiName peoplesend
* @apiParam (参数) {String} id   用户id
* @apiParam (参数) {String} online   用户发布状态 1：发布,2：回收
* @apiSampleRequest /people/peoplesend
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*     id: 23
*     online: 1
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "回收成功",
*      "code": 0
*   }
*/
async function peoplesend(req, res) {
    let result = await peopleSend(req.body);
    res.json(new ReturnModel(result));
}
/**
* 设置推荐人-后台
* @api {post} /people/peopleSet 设置推荐人-后台
* @apiDescription 管理员设置推荐人简介
* @apiName peopleSet
* @apiParam (参数) {String} id   用户id
* @apiParam (参数) {String} synopsis   推荐人简介
* @apiSampleRequest /people/peopleSet
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*     id: 23,
*     synopsis: "推荐人简介"
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "设置成功",
*      "code": 0
*   }
*/
async function peopleset(req, res){
    let result = await peopleSet(req.body);
    res.json(new ReturnModel(result));
}
/**
* 取消置顶-后台
* @api {post} /people/peoplenotop 取消置顶-后台
* @apiDescription 管理员设置取消置顶
* @apiName peoplenotop
* @apiParam (参数) {String} id   用户id
* @apiSampleRequest /people/peoplenotop
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*     id: 23,
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "取消置顶成功",
*      "code": 0
*   }
*/
async function peoplenotop(req, res){
    let result = await peopleNoTop(req.body);
    res.json(new ReturnModel(result));
}
/**
* 相册解锁
* @api {post} /people/unlock 相册解锁
* @apiDescription 相册解锁查看心仪用户照片
* @apiName unlock
* @apiParam (参数) {Object} code 心仪对象code 
* @apiParam (参数) {Object} fcode 申请用户code
* @apiSampleRequest /people/unlock
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*    {
*     code: 290464549598,
*     fcode: 12321231598,
*    }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "申请已发送，等待对方通过",
*      "code": 0
*   }
*/
async function unlock(req, res){
    let result = await UnLock(req.body);
    res.json(new ReturnModel(result));
}

/**
* 设置用户备注
* @api {post} /people/saveremarks 设置用户备注
* @apiDescription 我的用户-设置用户备注
* @apiName saveremarks
* @apiParam (参数) {String} id 用户id
* @apiParam (参数) {String} remarks 备注信息
* @apiSampleRequest /people/saveremarks
* @apiGroup people-用户
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "id": 23,
*       "remarks": '华为总监占总',
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "备注成功",
*      "code": 0
*   }
*/
async function saveremarks(req, res) {
    let result = await saveRemarks(req.body);
    res.json(new ReturnModel(result));
}

async function sendhomeAPI(req, res){
    let result = await sendhome(req.body);
    res.json(new ReturnModel(result));
}


module.exports = function (app) {
    let base_url = '/api/people';

    app.post(base_url + '/save', save);
    app.post(base_url + '/saveBack', saveBack);
    app.post(base_url + '/list', list);
    app.post(base_url + '/listBack', listBack);
    app.post(base_url + '/queryOne', QueryOne);
    app.post(base_url + '/QueryOneBack', QueryOneBack);
    app.post(base_url + '/personlabelSave', personlabelsave);
    app.post(base_url + '/persondesSave', persondessave);
    app.post(base_url + '/peopleimport', peopleimport);
    app.post(base_url + '/peopleimport_hand', peopleimport_hand);
    app.post(base_url + '/myinviter', myinviter);
    app.post(base_url + '/peoplesecret', peoplesecret);
    app.post(base_url + '/peoplesecretEdit', peoplesecretEdit);
    app.post(base_url + '/peopleexport', peopleexport);
    app.post(base_url + '/peopleSend', peoplesend);
    app.post(base_url + '/peopleSet', peopleset);
    app.post(base_url + '/peopleNoTop', peoplenotop);
    app.post(base_url + '/unlock', unlock);
    app.post(base_url + '/saveremarks', saveremarks);
    app.post(base_url + '/sendhome', sendhomeAPI);
}
